/*工资核对记录*/
import 'package:flutter/cupertino.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:frametrim/appviews/salaryRecordQueryView.dart';
import 'package:frametrim/appviews/salaryRecordView.dart';
import 'package:frametrim/utility/deviceUtils.dart';
import 'package:frametrim/utility/sq_color.dart';
import 'package:frametrim/views/appbar_black.dart';
import 'package:frametrim/views/dialogs/commonDialog.dart';

class SalaryRecordsPage extends StatefulWidget {
  late String id;

  @override
  State<StatefulWidget> createState() => SalaryRecordsState();

  SalaryRecordsPage(this.id);
}

class SalaryRecordsState extends State<SalaryRecordsPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: AnnotatedRegion(
        value: SystemUiOverlayStyle.dark,
        child: Container(
          child: Column(
            children: <Widget>[
              AppbarCenterTitle(
                title: '工资条',
                imgStr: 'image/imv_back.png',
                titleColor: SQColor.black,
              ),
              Expanded(
                  child: MediaQuery.removePadding(
                context: context,
                child: ListView(
                  children: <Widget>[
                    buildWarmPrompt(),
                  ],
                ),
                removeTop: true,
              ))
            ],
          ),
        ),
      ),
    );
  }

/*温馨提示*/
  Widget buildWarmPrompt() {
    return Container(
      padding: EdgeInsets.symmetric(horizontal: 10,vertical: 20),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Text(
            '温馨提示',
            style: TextStyle(fontSize: 16, color: SQColor.color_222222),
          ),
          SizedBox(
            height: 10,
          ),
          RichText(
              text: TextSpan(children: <TextSpan>[
            TextSpan(
              text: '您的工资由飞翔劳务公司核算，如有疑问联系负责人：',
              style: TextStyle(fontSize: 14, color: SQColor.color_222222),
            ),
            TextSpan(
                text: '18339995540',
                style: TextStyle(fontSize: 14, color: SQColor.primary),
                recognizer: TapGestureRecognizer()
                  ..onTap = () async {
                    /*点击事件*/
                    createPhoneDialog('18339995540');
                  }),
          ])),
          buildListView()
        ],
      ),
    );
  }

  /*列表布局*/
  Widget buildListView() {
    return Column(
      children: _listData(),
    );
  }

  /*列表数据*/
  List<Widget> _listData() {
    List<Widget> children = [];
    children.add(SalaryRecordViuew());
    children.add(SalaryRecordQueryViuew());
    children.add(SalaryRecordViuew());
    return children;
  }

/*拨打电话弹窗*/
  void createPhoneDialog(String phone) {
    showDialog<void>(
      context: context,
      barrierDismissible: true,
      builder: (BuildContext dialogContext) {
        return CommonDialog(
          title: '拨打电话',
          content: '18339995540？',
          button_left: '取消',
          onPress: () {
            DeviceUtils.launchTelURL(phone);
          },
        );
      },
    );
  }
}
